package com.tanjie.blackbean.schedule.support;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;

/**
 * @author: tanjie
 * @date: 2022-04-14
 **/
public final class ScheduledFutureHolder {

    public ScheduledFutureHolder() {
        futureMap = new HashMap<>();
    }

    private final Map<String, ScheduledFuture<?>> futureMap;

    public void add(String taskName, ScheduledFuture<?> future) {
        futureMap.put(taskName, future);
    }

    public ScheduledFuture<?> get(String taskName) {
        return futureMap.get(taskName);
    }

    public void remove(String taskName) {
        futureMap.remove(taskName);
    }

    public Map<String, ScheduledFuture<?>> all() {
        return futureMap;
    }

}
